import zipfile
import os as os
import time


def zip_files(filepath, zip_name):
    zip = zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED)
    zip.write(filepath)


if __name__ == '__main__':
    nowDate = time.strftime("%Y%m%d", time.localtime())  # 获取当前日期
    path = './'
    filelist = os.listdir(path)

    for file in filelist:
        if file.split('.')[1] != 'py':
            name = file.split('.')[0]
            print(name)
            filepath = path + file
            zip_file = './' + name + '_公安_' + nowDate + '.zip'  # 压缩包名字
            zip_files(filepath, zip_file)

